package util

// IfThenElse evaluates a condition, if true returns the first parameter otherwise the second
func IfThenElse(condition bool, a , b interface{}) interface{} {
	if condition {
			return a
	}
	return b
}

// Int32IfThenElse evaluates a condition, if true returns the first parameter otherwise the second as type int32
func IntIfThenElse (condition bool, a, b int) int {
	r := IfThenElse(condition , a, b)
	return r.(int)
}

// UInt32IfThenElse evaluates a condition, if true returns the first parameter otherwise the second as type uint32
func UInt32IfThenElse (condition bool, a, b uint32) uint32 {
	r := IfThenElse(condition , a, b)
	return r.(uint32)
}

// Int32IfThenElse evaluates a condition, if true returns the first parameter otherwise the second as type int32
func Int32IfThenElse (condition bool, a, b int32) int32 {
	r := IfThenElse(condition , a, b)
	return r.(int32)
}

// Int64IfThenElse evaluates a condition, if true returns the first parameter otherwise the second as type int64
func Int64IfThenElse (condition bool, a, b int64) int64 {
	r := IfThenElse(condition , a, b)
	return r.(int64)
}

// StringIfThenElse evaluates a condition, if true returns the first parameter otherwise the second as type string
func StringIfThenElse (condition bool, a, b string) string {
	r := IfThenElse(condition , a, b)
	return r.(string)
}